import type { StockChangeVO, StockChangeForm, StockChangeQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询库存变更明细列表
* @param params
* @returns 库存变更明细列表
*/
export function stockChangeList(params?: StockChangeQuery) {
  return requestClient.get<PageResult<StockChangeVO>>('/hm/stockChange/list', { params });
}

/**
 * 导出库存变更明细列表
 * @param params
 * @returns 库存变更明细列表
 */
export function stockChangeExport(params?: StockChangeQuery) {
  return commonExport('/hm/stockChange/export', params ?? {});
}

/**
 * 查询库存变更明细详情
 * @param changeId id
 * @returns 库存变更明细详情
 */
export function stockChangeInfo(changeId: ID) {
  return requestClient.get<StockChangeVO>(`/hm/stockChange/${changeId}`);
}

/**
 * 新增库存变更明细
 * @param data
 * @returns void
 */
export function stockChangeAdd(data: StockChangeForm) {
  return requestClient.postWithMsg<void>('/hm/stockChange', data);
}

/**
 * 更新库存变更明细
 * @param data
 * @returns void
 */
export function stockChangeUpdate(data: StockChangeForm) {
  return requestClient.putWithMsg<void>('/hm/stockChange', data);
}

/**
 * 删除库存变更明细
 * @param changeId id
 * @returns void
 */
export function stockChangeRemove(changeId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/hm/stockChange/${changeId}`);
}
